package com.ytjj.qmyx.admin.controller;

import com.ytjj.common.api.CommonResult;
import com.ytjj.qmyx.admin.annotation.OperLog;
import com.ytjj.qmyx.admin.constants.SysLogConstants;
import com.ytjj.qmyx.admin.model.YxReports;
import com.ytjj.qmyx.admin.model.dto.YxReportsDto;
import com.ytjj.qmyx.admin.model.vo.ChattingRecordsVo;
import com.ytjj.qmyx.admin.service.RePortsService;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/reports")
@AllArgsConstructor
public class ReportsController {

    private RePortsService rePortsService;

    @PostMapping("/list")
    @OperLog(operModule = "举报模块",operDesc = "查询所有举报信息",operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult selectReportsPage(@RequestBody YxReportsDto yxReportsDto) {
        return CommonResult.success(rePortsService.selectReportsPage(yxReportsDto));
    }

    @GetMapping("/findReportSession")
    @OperLog(operModule = "举报模块",operDesc = "查询聊天记录",operType = SysLogConstants.OPERATION_SELECT)
    public CommonResult<List<ChattingRecordsVo>> findReportSession(@RequestParam Integer sessionId) {
        return CommonResult.success(rePortsService.findReportSession(sessionId));
    }

    @PostMapping("/updateStatusDoHandelr")
    @OperLog(operModule = "举报模块",operDesc = "修改状态为已处理",operType = SysLogConstants.OPERATION_UPDATE)
    public CommonResult updateStatusDoHandelr(@RequestBody YxReports yxReports) {
        return CommonResult.success(rePortsService.updateStatusDoHandelr(yxReports.getAdminId(),yxReports.getId()));
    }

    @GetMapping("/doHandelNoChat")
    @OperLog(operModule = "举报模块",operDesc = "禁止聊天",operType = SysLogConstants.OPERATION_UPDATE)
    public CommonResult updateStatusNoChat(@RequestParam Integer userId,
                                @RequestParam Integer date,
                                @RequestParam Integer adminId,
                                @RequestParam Integer id) {
        return CommonResult.success(rePortsService.updateStatusNoChat(userId,adminId,id,date));
    }
}
